﻿
Imports remotecall

Public Class rc4Emitter
    Inherits rcEmitter(Of rcclient4, fromBytes())

    Public Sub New(ByVal host As String,
                   ByVal port As Int32,
                   Optional ByVal holdtimeMs As Int64 = tcpTalk4.defaultHoldTimeMs,
                   Optional ByVal livetimeMs As Int64 = tcpTalk4.defaultLiveTimeMs)
        MyBase.New(host, port, holdtimeMs, livetimeMs)
    End Sub

    Protected Overrides Function create_client(
                                    ByVal host As String,
                                    ByVal port As Int32,
                                    Optional ByVal holdtimeMs As Int64 = tcpTalk4.defaultHoldTimeMs,
                                    Optional ByVal livetimeMs As Int64 = tcpTalk4.defaultLiveTimeMs) As rcclient4
        Return New rcclient4(host, port, holdtimeMs, livetimeMs)
    End Function

    Protected Overrides Function invoke(ByVal client As rcclient4,
                                        ByVal name As String,
                                        ByRef ec As eventComb,
                                        ByVal rtn As pointer(Of fromBytes()),
                                        ByVal job As ijob) As Boolean
        Return client.invoke(name, ec, rtn, job)
    End Function

    Protected Overrides Function parse_output_ijob(ByVal o() As fromBytes, ByRef job As ijob) As Boolean
        Return o(0).cast(Of ijob)(job)
    End Function

    Protected Overrides Function parse_output_valid(ByVal o() As fromBytes) As Boolean
        Return Not o Is Nothing AndAlso o.Length() = 1
    End Function
End Class
